package com.tikou.androidadvanceproject.proxy;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;

import java.lang.reflect.Proxy;

/**
 * Created by Tikou on 2017/10/26.
 * 作者：TianNuo
 * 邮箱：1320917731@qq.com
 * 说明：代理模式测试
 * 参考：http://www.jianshu.com/p/b9dc2596ce95
 */

public class ProxyActivity extends AppCompatActivity{
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    /*    People people = new People();
        BankSaler saler = new BankSaler(people);
        saler.applyBank();*/

        testProxy();
    }

    private void testProxy() {
        People people = new People();
        IBank bank = (IBank) Proxy.newProxyInstance(IBank.class.getClassLoader(),
                new Class<?>[]{IBank.class},new DynamicBankProxy(people)
                );
        bank.applyBank();
    }
}
